Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.SourceRange


        /** Apply highlights to the specified identifiers */
        public void applyHighlights() {
            removeHighlights();
            try {
                for (final AnalysedIdentifier referenceIdentifier : identifiers) {
                    SourceRange referenceIdentifierOffsetRange = referenceIdentifier.getOffsetRange();
                    AdvancedCALEditor.EditorLocation editorLoc = getEditorTokenOffset(referenceIdentifierOffsetRange.getStartLine(), referenceIdentifierOffsetRange.getStartColumn(),
                            referenceIdentifier.getName().length());
                    int posStart = editorLoc.getStartOffset();
                    int posEnd = editorLoc.getEndOffset();
                    Object highlightRef = highlighter.addHighlight(posStart, posEnd, new DefaultHighlighter.DefaultHighlightPainter(highlightColor));
                    highlights.add(highlightRef);
View Full Code Here


         */
        void start() {
           
            // Put caret at the end of the identifier being edited
            try {
                SourceRange startIdentifierOffsetRange = startIdentifier.getOffsetRange();
                setCaretPosition(convertPositionToEditorOffset(startIdentifierOffsetRange.getStartLine(), startIdentifierOffsetRange.getStartColumn()) + caretPos);
            } catch (BadLocationException ex) {
                throw new IllegalStateException("Identifier contains illegal position in editor.");
            }
           
            // Remove listeners from the editor and add our own
View Full Code Here

           
            // Revert the identifiers to their original name
           
            for (final AnalysedIdentifier identifier : symbolPositions) {
                try {
                    SourceRange identifierOffsetRange = identifier.getOffsetRange();
                    int pos = (convertPositionToEditorOffset(identifierOffsetRange.getStartLine(), identifierOffsetRange.getStartColumn()));
                    select(pos, pos + newName.length());
                    replaceSelection(oldName);
                } catch (BadLocationException ex) {
                    throw new IllegalStateException("Identifier contains illegal position in editor.");
                }
View Full Code Here

           
            // Now find the code expression of the definition
           
            String expression = "";
            try {
                SourceRange definitionIdentifierOffsetRange = definitionIdentifier.getOffsetRange();
                expression = getExpressionFrom(definitionIdentifierOffsetRange.getStartLine(), definitionIdentifierOffsetRange.getStartColumn());
            } catch (BadLocationException ex) {
                throw new IllegalStateException("Expression gathering tried to go past end of buffer.");
            }
            return "<html><body>" +
                   ToolTipHelpers.wrapTextToHTMLLines(GemCutter.getResourceString("CEP_LocalVariable") + ": " + expression + " ..", this) +
View Full Code Here

                // Check position of identifier name
               
                // The positions are shifted by 1 because identifier positions
                // are 1-based, while Document positions are 0-based.
               
                SourceRange identifierOffsetRange = identifier.getOffsetRange();
                int column = identifierOffsetRange.getStartColumn() - 1;

                int identifierEndLine = identifierOffsetRange.getEndLine() - 1;

                if ((identifierEndLine == indexLine) &&
                    (column < mouseColumn) &&
                    (mouseColumn <= column + identifier.getName().length() + 1)) {
                   
                    return identifier;
                }
               
                // Check position of identifier module name
                // This is done separately because an identifier name
                // may be separated from its module name (eg: "Prelude    .    not")
               
                if (identifier.hasRawModuleSourceRange()) {
               
                    SourceRange identifierOffsetModuleNameRange = identifier.getOffsetModuleNameRange();
                   
                    int startLine = identifierOffsetModuleNameRange.getStartLine() - 1;
                    int startColumn = identifierOffsetModuleNameRange.getStartColumn() - 1;
                    int endLine = identifierOffsetModuleNameRange.getEndLine() - 1;
                    int endColumn = identifierOffsetModuleNameRange.getEndColumn() - 1;
                   
                    if ((startLine <= indexLine) && (indexLine <= endLine) &&
                        (startColumn < mouseColumn) && (mouseColumn <= endColumn)) {
                       
                        return identifier;
View Full Code Here

     */
    private AmbiguityOffset getAmbiguityOffset(CodeAnalyser.AnalysedIdentifier identifier) {

        try {

            SourceRange identifierOffsetRange = identifier.getOffsetRange();
            EditorLocation offset = getEditorTokenOffset(identifierOffsetRange.getStartLine(), identifierOffsetRange.getStartColumn(), identifier.getName().length());
            return new AmbiguityOffset(identifier, offset);
           
        } catch (BadLocationException ex) {
            throw new IllegalArgumentException("invalid location trying to convert ambiguous identifier source position");
        }
View Full Code Here

        }
        try {
           
            for (final AnalysedIdentifier identifier : analysedIdentifiers) {
               
                SourceRange identifierOffsetRange = identifier.getOffsetRange();
                int identifierStartOffset = convertPositionToEditorOffset(identifierOffsetRange.getStartLine(), identifierOffsetRange.getStartColumn());
                int identifierEndOffset = identifierStartOffset + identifier.getName().length();
                if (identifierStartOffset >= offsetStart && identifierEndOffset <= offsetEnd) {
                    containedIdentifiers.add(identifier);
                }
            }
View Full Code Here

TOP

Related Classes of org.openquark.cal.compiler.SourceRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.