org.eclipse.ease

## Interface ICodeParser

All Known Implementing Classes:
  AbstractCodeParser, AbstractCompletionParser, JavaScriptCodeParser, PythonCodeParser

    public interface ICodeParser

Parser interface for source code parsers to extract relevant script data.

### Method Summary

All Methods Instance Methods Abstract Methods
`ICompletionContext` `getContext(IScriptEngine scriptEngine, Object resource, String contents, int position, int selectionRange)` Parse the given piece of code into a language specific `ICompletionContext`.
`String` `getHeaderComment(InputStream stream)` Parses the file for a comment section at the beginning.
`SignatureInfo` `getSignatureInfo(InputStream stream)` Gets signature, certificates, provider and message-digest algorithm of signature, and content excluding signature block.
`boolean` `isAcceptedBeforeHeader(String line)` Verify if a line of code is accepted before the header comment section.

### Method Detail

#### getHeaderComment

    String getHeaderComment(InputStream stream)

Parses the file for a comment section at the beginning.

Parameters:
  `stream` - code content stream
Returns:
  comment data without decoration characters (eg: '*' at beginning of each line)

#### isAcceptedBeforeHeader

    boolean isAcceptedBeforeHeader(String line)

Verify if a line of code is accepted before the header comment section. This allows special magic tokens to be placed before the header comment as some script languages depend on that.

Parameters:
  `line` - line of code
Returns:
  `true` when line is accepted before the comment header

#### getContext

    ICompletionContext getContext(IScriptEngine scriptEngine,
                                  Object resource,
                                  String contents,
                                  int position,
                                  int selectionRange)

Parse the given piece of code into a language specific `ICompletionContext`.

Parameters:
  `scriptEngine` - running script engine
  `resource` - resource instance to be parsed
  `contents` - code to be parsed (only up to cursor position)
  `position` - cursor position within contents
  `selectionRange` - amount of selected characters from cursor position
Returns:
  `ICompletionContext` with parsed information if successful, `null` in case invalid syntax given.

#### getSignatureInfo

    SignatureInfo getSignatureInfo(InputStream stream)
                            throws ScriptSignatureException

Gets signature, certificates, provider and message-digest algorithm of signature, and content excluding signature block.

Parameters:
  `stream` - provide `InputStream` to get signature from
Returns:
  `SignatureInfo` instance containing signature, certificates, provider and message-digest algorithm, and content excluding signature block or `null` if signature is not found or is not in proper format
Throws:
  `ScriptSignatureException` - when there is text after signature block or error occurs while reading from provided input stream