Java Code Examples for org.netbeans.api.java.source.CompilationInfo#getJavaSource()
The following examples show how to use
org.netbeans.api.java.source.CompilationInfo#getJavaSource() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntroduceConstantFix.java From netbeans with Apache License 2.0 | 6 votes |
/** * Creates an 'introduce constant' fix. * * Note: the fix will not reference CompilationInfo and will remember only handles to TreePaths. * * @param resolved the path for expression or variable declaration to convert * @param info compilation context * @param value the actual expression or a variable initializer. * @param guessedName proposed name * @param numDuplicates number of other duplicates * @param offset offset for the hint * @param variableRewrite if variable name should be changed (?) * @param cancel cancel flag * @return */ static IntroduceFieldFix createConstant(TreePath resolved, CompilationInfo info, TreePath value, String guessedName, int numDuplicates, int offset, boolean variableRewrite, AtomicBoolean cancel) { CodeStyle cs = CodeStyle.getDefault(info.getFileObject()); boolean isConstant = checkConstantExpression(info, value); TreePath constantTarget = isConstant ? findAcceptableConstantTarget(info, resolved) : null; if (!isConstant || constantTarget == null || cancel.get()) { return null; } TreePathHandle h = TreePathHandle.create(resolved, info); String varName; if (variableRewrite) { varName = guessedName; } else { String proposed = Utilities.toConstantName(guessedName); varName = Utilities.makeNameUnique(info, info.getTrees().getScope(constantTarget), proposed, cs.getStaticFieldNamePrefix(), cs.getStaticFieldNameSuffix()); } ClassTree clazz = (ClassTree)constantTarget.getLeaf(); Element el = info.getTrees().getElement(constantTarget); if (el == null || !(el.getKind().isClass() || el.getKind().isInterface())) { return null; } IntroduceConstantFix fix = new IntroduceConstantFix(h, info.getJavaSource(), varName, numDuplicates, offset, TreePathHandle.create(constantTarget, info)); fix.setTargetIsInterface(clazz.getKind() == Tree.Kind.INTERFACE); return fix; }
Example 2
Source File: ConvertAnonymousToInner.java From netbeans with Apache License 2.0 | 5 votes |
static Fix computeFix(CompilationInfo info, int selStart, int selEnd, boolean onlyHeader) { TreePath tp = findNCT(info, info.getTreeUtilities().pathFor((selStart + selEnd + 1) / 2), selStart, selEnd, onlyHeader); if (tp == null) { tp = findNCT(info, info.getTreeUtilities().pathFor((selStart + selEnd + 1) / 2 + 1), selStart, selEnd, onlyHeader); } if (tp == null) { return null; } return new FixImpl(TreePathHandle.create(tp, info), info.getJavaSource(), info.getFileObject()); }
Example 3
Source File: ImplementAllAbstractMethods.java From netbeans with Apache License 2.0 | 4 votes |
protected ImplementFixBase(CompilationInfo info, TreePath p, TypeElement el, boolean displayUI) { this.source = info.getJavaSource(); this.handle = TreePathHandle.create(p, info); this.implementType = ElementHandle.create(el); this.displayUI = displayUI; }
Example 4
Source File: ImplementAllAbstractMethods.java From netbeans with Apache License 2.0 | 4 votes |
protected ImplementFixBase(CompilationInfo info, TypeElement el, boolean displayUI) { this.source = info.getJavaSource(); this.handle = TreePathHandle.create(el, info); this.implementType = ElementHandle.create(el); this.displayUI = displayUI; }