private void appendDescriptors(final ASTNode node, final Document document, final List<FoldingDescriptor> descriptors) { if (node.getElementType() == GCMTypes.CLASS_DECLARATION || node.getElementType() == GCMTypes.CUSTOM_TYPE_DECLARATION) { TextRange fullRange = node.getTextRange(); if (fullRange.getEndOffset() - fullRange.getStartOffset() > 0) { try { int startOffset = fullRange.getStartOffset() + document.getText(fullRange).indexOf("{") + 1; int endOffset = fullRange.getEndOffset() - 1; if (startOffset < endOffset) { TextRange shortRange = new TextRange(startOffset, fullRange.getEndOffset() - 1); if (shortRange.getEndOffset() - shortRange.getStartOffset() > 1) { descriptors.add(new FoldingDescriptor(node, shortRange)); } } } catch (Throwable e) { } } } ASTNode child = node.getFirstChildNode(); while (child != null) { appendDescriptors(child, document, descriptors); child = child.getTreeNext(); } }
@NotNull @Override public String getSelectorPart() { StringBuilder builder = new StringBuilder(); ASTNode child = getNode().getFirstChildNode(); if (child != null) { builder.append(child.getText()); child = child.getTreeNext(); } while (child != null && AppleScriptTokenTypesSets.COMMENT_OR_WHITE_SPACE.contains(child.getElementType())) child = child.getTreeNext(); if (child != null && child.getElementType() == AppleScriptTypes.COLON) { builder.append(child.getText()); } return builder.toString(); }
@Override public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { PsiElement classElement = null; if (element instanceof TSDatablockDecl) { TSDatablockDecl db = (TSDatablockDecl) element; //Find the first id node, this is kinda wonky since we have to account for whitespace nodes //datablock ClassName(...) ASTNode node = db.getNode(); if (node == null) { return; } node = node.findChildByType(TSTypes.ID); if (node == null) { return; } classElement = node.getPsi(); } else if (element instanceof TSObjectExpr) { TSObjectExpr obj = (TSObjectExpr) element; //Class name should be the second thing in the element: // new ClassName(...) classElement = PsiTreeUtil.getChildOfType(obj, TSClassNameExpr.class); if (classElement == null) { return; } classElement = classElement.getFirstChild(); } if (classElement == null) { return; } //Only annotate if it's an id, can't really tell if it's an expr if (classElement.getNode().getElementType().equals(TSTypes.ID)) { createSuccessAnnotation(classElement, holder, TSSyntaxHighlighter.CLASSNAME); } }
public static String getArgList(TSFnDeclStmt element) { ASTNode argNode = element.getNode().findChildByType(TSTypes.VAR_LIST); if (argNode != null) { return "(" + argNode.getText() + ")"; } else { return "()"; } }
@Override protected List<Block> buildChildren() { ASTNode node = this.getNode().getFirstChildNode(); List<Block> blocks = new ArrayList<>(); while (node != null) { if (node.getElementType() != TokenType.WHITE_SPACE) { CsvBlockElement block = new CsvBlockElement(node, formattingInfo, this); blocks.add(block); } node = node.getTreeNext(); } return blocks; }
@Nullable @Override public String getPlaceholderText(@NotNull ASTNode node) { IElementType elementType = node.getElementType(); if (elementType == RmlTypes.INSTANCE.COMMENT) { return "/*...*/"; } else if (elementType == OclTypes.INSTANCE.COMMENT) { return "(*...*)"; } return "{...}"; }
@Nullable @Override public String getPlaceholderText(@NotNull final ASTNode node) { Validate.notNull(node); return ImpexFoldingPlaceholderBuilderFactory.getPlaceholderBuilder().getPlaceholder(node.getPsi()); }
Indent getChildIndent(final ASTNode node) { final IElementType elementType = node.getElementType(); if (elementType == BLOCK_BODY || elementType == TOP_BLOCK_BODY || elementType == SCRIPT_BODY) { return Indent.getNormalIndent(); } return Indent.getNoneIndent(); }
public static PsiElement setName(CrystalProperty element, String newName) { ASTNode keyNode = element.getNode().findChildByType(CrystalTypes.KEY); if (keyNode != null) { CrystalProperty property = CrystalElementFactory.createProperty(element.getProject(), newName); ASTNode newKeyNode = property.getFirstChild().getNode(); element.getNode().replaceChild(keyNode, newKeyNode); } return element; }
public static String getValue(CrystalProperty element) { ASTNode valueNode = element.getNode().findChildByType(CrystalTypes.VALUE); if (valueNode != null) { return valueNode.getText(); } else { return null; } }
Wrap createChildWrap(ASTNode child, Wrap defaultWrap, Wrap childWrap) { final IElementType childType = child.getElementType(); final IElementType elementType = myNode.getElementType(); if (childType == COMMA) return defaultWrap; return defaultWrap; }
public static String getMatchingClassName(CptMapping element) { ASTNode keyNode = element.getNode().findChildByType(CptTypes.CLASS_NAME); if (keyNode != null) { // IMPORTANT: Convert embedded escaped spaces to simple spaces return keyNode.getText().replaceAll("\\\\ ", " "); } else { return null; } }
@Override protected List<Block> buildChildren() { List<ASTNode> todoNodes = new ArrayList<>(); List<Block> blocks = new ArrayList<>(); todoNodes.add(getNode().getFirstChildNode()); CsvBlockField currentField = null; while (todoNodes.size() > 0) { ASTNode node = todoNodes.remove(todoNodes.size() - 1); if (node == null) { continue; } IElementType elementType = node.getElementType(); todoNodes.add(node.getTreeNext()); if (elementType == CsvTypes.RECORD) { todoNodes.add(node.getFirstChildNode()); } else if (elementType == CsvTypes.FIELD) { currentField = new CsvBlockField(node, formattingInfo); if (currentField.getTextLength() > 0) { blocks.add(currentField); } } else if (elementType == CsvTypes.COMMA || elementType == CsvTypes.CRLF) { blocks.add(new CsvBlockElement(node, formattingInfo, currentField)); } else if (elementType != TokenType.WHITE_SPACE && node.getTextLength() > 0) { blocks.add(new CsvDummyBlock(node, formattingInfo)); } } return blocks; }
protected FlexibleSearchBlock( @NotNull final ASTNode node, @Nullable final Wrap wrap, @Nullable final Alignment alignment, @NotNull final SpacingBuilder spacingBuilder ) { super(node, wrap, alignment); this.spacingBuilder = spacingBuilder; }
public ImpexModifiersImpl(ASTNode node) { super(node); }
public GCMAttributeDefaultImpl(ASTNode node) { super(node); }
public MasUseClauseImpl(ASTNode node) { super(node); }
public FlexibleSearchCommonValueExpressionImpl(ASTNode node) { super(node); }
public AppleScriptHandlerInterleavedParametersSelectorPartImpl(ASTNode node) { super(node); }
@Override public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode astNode, ASTNode astNode1) { return SpaceRequirements.MAY; }
public ActionSpecIdentifierImpl(ASTNode node) { super(node); }
public FlexibleSearchBooleanPrimaryImpl(ASTNode node) { super(node); }
public TSNamedElementImpl(@NotNull ASTNode node) { super(node); }
public PsiTypeImpl(@NotNull MlTypes types, @NotNull ASTNode node) { super(node); m_types = types; }
public AppleScriptLabeledParameterDeclarationListImpl(ASTNode node) { super(node); }
@NotNull @Override public PsiElement createElement(ASTNode node) { return ActionSpecTypes.Factory.createElement(node); }
public CptTemplateVariableValueGImpl(ASTNode node) { super(node); }
public ModuleTermImpl(ASTNode node) { super(node); }
public TestEventuallyRuleImpl(ASTNode node) { super(node); }
public AppleScriptLogicalOrExpressionImpl(ASTNode node) { super(node); }
public ModuleUseClauseImpl(ASTNode node) { super(node); }
public NamespaceDeclarationMixin(NamespaceDeclarationStub stub, IElementType type, ASTNode node) { super(stub, type, node); }
public SoyStubBasedPsiElementBase(T stub, IElementType nodeType, ASTNode node) { super(stub, nodeType, node); }
@NotNull public PsiElement createElement(ASTNode node) { return PsiElementFactory.createElement(OclTypes.INSTANCE, node); }
private static boolean isWhiteSpace(final ASTNode node) { return node != null && (AppleScriptPsiImplUtil.isWhiteSpaceOrNls(node) || node.getTextLength() == 0); }
public AppleScriptDictionaryCommandNameImpl(ASTNode node) { super(node); }
public FlexibleSearchSelectListImpl(ASTNode node) { super(node); }
public FlexibleSearchCharacterValueFunctionImpl(ASTNode node) { super(node); }
public ModuleDropActionImpl(ASTNode node) { super(node); }