private static List<HintFix> getFixes(Collection<Attribute> attributes, OpenTag element, RuleContext context) { List<HintFix> fixes = new ArrayList<>(); Snapshot snap = context.parserResult.getSnapshot(); for(Attribute aName : attributes) { fixes.add(new AddAttributeToSourceFix(aName, element, snap)); } if(attributes.size() > 1) { //add all attributes at once fix fixes.add(new AddAttributeToSourceFix(attributes, element, snap)); } return fixes; }
private static List<HintFix> getFixes(String elementName, RuleContext context) { List<HintFix> fixes = new ArrayList<>(); Snapshot snap = context.parserResult.getSnapshot(); fixes.add(new RemoveElementFix(elementName, null, snap)); fixes.add(new EditProjectsConfFix(snap)); return fixes; }
public boolean appliesTo(RuleContext context) { return JsTokenId.JAVASCRIPT_MIME_TYPE.equals(context.parserResult.getSnapshot().getSource().getMimeType()); }
@Override public void run(ResultIterator resultIterator) throws Exception { results[0] = resultIterator.getParserResult(parserResult.getSnapshot().getOriginalOffset(0) - 2); }
@Override public final OffsetRange getOffsetRange(ParserResult result) { int start = result.getSnapshot().getOriginalOffset(offsetRange.getStart()); if (start < 0) { return OffsetRange.NONE; } int end = result.getSnapshot().getOriginalOffset(offsetRange.getEnd()); return new OffsetRange(start, end); }
@Override public void run(ParserResult result, SchedulerEvent event) { final CSSUpdater updater = CSSUpdater.getDefault(); if (!updater.isStarted()) { return; } String sourceMimeType = result.getSnapshot().getSource().getMimeType(); if (!hasFatalErrors(result) && "text/css".equals(sourceMimeType)) { // NOI18N updater.update(result.getSnapshot().getSource().getFileObject(), result.getSnapshot().getText().toString()); } }
String getUnigueNameForAnonymObject(ParserResult parserResult) { FileObject fo = parserResult.getSnapshot().getSource().getFileObject(); if (fo != null) { return fo.getName() + ANONYMOUS_OBJECT_NAME_START + anonymObjectCount++; } return ANONYMOUS_OBJECT_NAME_START + anonymObjectCount++; }
private Hint getDescriptor(Operation operation, String description, RuleContext context, BaseDocument baseDoc, OffsetRange range) { int DEFAULT_PRIORITY = 292; HintFix fixToApply = new SimpleFix(operation, description, baseDoc, context); List<HintFix> fixList = new ArrayList<>(1); fixList.add(fixToApply); // FIXME parsing API Hint descriptor = new Hint(this, fixToApply.getDescription(), context.parserResult.getSnapshot().getSource().getFileObject(), range, fixList, DEFAULT_PRIORITY); return descriptor; }
private GroovyStructureItem(ASTElement node, ParserResult info) { this.node = node; this.kind = node.getKind(); this.info = info; // FIXME true or false ? this.doc = (BaseDocument) info.getSnapshot().getSource().getDocument(false); }
private JavaSource createJavaSource() { FileObject fileObject = info.getSnapshot().getSource().getFileObject(); if (fileObject == null) { return null; } // get the JavaSource for our file. JavaSource javaSource = JavaSource.create(ClasspathInfo.create(fileObject)); if (javaSource == null) { LOG.log(Level.FINEST, "Problem retrieving JavaSource from ClassPathInfo, exiting."); return null; } return javaSource; }
public static QuerySupport get(final ParserResult info) { return get(info.getSnapshot().getSource().getFileObject()); }
public CompleteElementHandler(CompletionContext context) { this.context = context; this.info = context.getParserResult(); FileObject fo = info.getSnapshot().getSource().getFileObject(); if (fo != null) { // FIXME index is broken when invoked on start this.index = GroovyIndex.get(QuerySupport.findRoots(fo, Collections.singleton(ClassPath.SOURCE), null, null)); } else { this.index = null; } }
private AstPath getPathFromInfo(final int caretOffset, final ParserResult info) { assert info != null; ASTNode root = ASTUtils.getRoot(info); // If we don't get a valid root-node from a valid CompilationInfo, // there's not much we can do. cf. # 150929 if (root == null) { return null; } // FIXME parsing API BaseDocument doc = (BaseDocument) info.getSnapshot().getSource().getDocument(true); return new AstPath(root, caretOffset, doc); }
public CustomElementHint(String elementName, RuleContext context, OffsetRange range) { super(RULE, Bundle.customHTMLElement(), context.parserResult.getSnapshot().getSource().getFileObject(), range, getFixes(elementName, context), 30); }
@SuppressWarnings("unchecked") public static ElementHandle createHandle(ParserResult result, final ASTElement object) { ASTNode root = ASTUtils.getRoot(result); return new GroovyElementHandle(root, object, result.getSnapshot().getSource().getFileObject()); }
public UnknownAttributes(Collection<String> attributeNames, String elementName, RuleContext context, OffsetRange range, boolean lineHint) { super(lineHint ? LINE_RULE : RULE, Bundle.unknownAttribute(Utils.attributeNames2String(attributeNames)), context.parserResult.getSnapshot().getSource().getFileObject(), range, getFixes(attributeNames, elementName, context), 30); }
public MissingRequiredAttributes(Collection<Attribute> attributes, OpenTag element, RuleContext context, OffsetRange range, boolean lineHint) { super(lineHint ? LINE_RULE : RULE, Bundle.missingRequiredAttributes(Utils.attributes2String(attributes)), context.parserResult.getSnapshot().getSource().getFileObject(), range, getFixes(attributes, element, context), 30); }
@Override public void run(RuleContext context, GroovyError error, List<Hint> result) { FileObject fo = context.parserResult.getSnapshot().getSource().getFileObject(); AddMethodStubsFix fix = findExistingFix(result); if (fix == null) { fix = new AddMethodStubsFix(error); OffsetRange range = HintUtils.getLineOffset(context, error); if (range != null) { result.add(new Hint(this, fix.getDescription(), fo, range, Collections.<HintFix>singletonList(fix), 100)); } } fix.addMethodSignature(getMethodName(error)); }
@Override public OffsetRange getOffsetRange(ParserResult result) { BaseDocument doc = (BaseDocument) result.getSnapshot().getSource().getDocument(false); int lineNumber = node.getLineNumber(); int columnNumber = node.getColumnNumber(); int start = ASTUtils.getOffset(doc, lineNumber, columnNumber); return new OffsetRange(start, start); }
public void implement() throws Exception { EditList edits = getEditList(); Position pos = edits.createPosition(varOffset); edits.apply(); if (pos != null && pos.getOffset() != -1) { JTextComponent target = GsfUtilities.getPaneFor(context.parserResult.getSnapshot().getSource().getFileObject()); if (target != null) { int start = pos.getOffset(); int end = start + varName.length(); target.select(start, end); } } }