public Document getDocument() { if (document == null) { FileObject fo = getFileObject(); if (fo == null) { return null; } document = GsfUtilities.getDocument(fo, true); } return document; }
@CheckForNull public static BaseDocument getDocument(RubyParseResult result, boolean forceOpen) { if (result != null) { Source source = result.getSnapshot().getSource(); return GsfUtilities.getDocument(source.getFileObject(), forceOpen); } return null; }
String content = null; BaseDocument bdoc = GsfUtilities.getDocument(fileObject, true); StringBuilder displayText = new StringBuilder(); try {
String content = null; BaseDocument bdoc = GsfUtilities.getDocument(info.getSnapshot().getSource().getFileObject(), true); try { bdoc.readLock();
/** Create a new element holder representing the given node in the same context as the given existing context */ public JsElementCtx(JsElementCtx ctx, Node node) { BaseDocument doc = GsfUtilities.getDocument(ctx.getFileObject(), true); try { if (doc != null) { doc.readLock(); } Element e = AstElement.getElement(ctx.getInfo(), node); initialize(ctx.getRoot(), node, e, ctx.getFileObject(), ctx.getInfo()); } finally { if (doc != null) { doc.readUnlock(); } } }
BaseDocument doc = GsfUtilities.getDocument(f, true); try { if (doc != null) {
@Override public void visit(MethodInvocation methodInvocation) { if (lineBounds.containsInclusive(methodInvocation.getStartOffset())) { String methName = CodeUtils.extractFunctionName(methodInvocation.getMethod()); if (StringUtils.hasText(methName)) { Collection<? extends TypeScope> allTypes = ModelUtils.resolveType(model, methodInvocation); if (allTypes.size() == 1) { TypeScope type = ModelUtils.getFirst(allTypes); ElementQuery.Index index = model.getIndexScope().getIndex(); Set<MethodElement> allMethods = ElementFilter.forName(NameKind.exact(methName)).filter(index.getAllMethods(type)); if (allMethods.isEmpty()) { assert type != null; FileObject fileObject = type.getFileObject(); BaseDocument document = fileObject != null ? GsfUtilities.getDocument(fileObject, true) : null; if (document != null && fileObject.canWrite()) { fix = new IntroduceMethodFix(document, methodInvocation, type); } } } } } super.visit(methodInvocation); }
assert type != null; FileObject fileObject = type.getFileObject(); BaseDocument document = fileObject != null ? GsfUtilities.getDocument(fileObject, true) : null; if (document != null && fileObject.canWrite() && type instanceof ClassScope) { fix = new IntroduceStaticFieldFix(document, fieldAccess, (ClassScope) type);
@Override public void visit(FieldAccess fieldAccess) { if (lineBounds.containsInclusive(fieldAccess.getStartOffset())) { String fieldName = CodeUtils.extractVariableName(fieldAccess.getField()); if (StringUtils.hasText(fieldName)) { Collection<? extends TypeScope> allTypes = ModelUtils.resolveType(model, fieldAccess); if (allTypes.size() == 1) { TypeScope type = ModelUtils.getFirst(allTypes); ElementQuery.Index index = model.getIndexScope().getIndex(); Set<FieldElement> allFields = ElementFilter.forName(NameKind.exact(fieldName)).filter(index.getAlllFields(type)); if (allFields.isEmpty()) { assert type != null; FileObject fileObject = type.getFileObject(); BaseDocument document = fileObject != null ? GsfUtilities.getDocument(fileObject, false) : null; if (document != null && fileObject.canWrite() && type instanceof ClassScope) { fix = new IntroduceFieldFix(document, fieldAccess, (ClassScope) type); } } } } } super.visit(fieldAccess); }
@Override public void visit(StaticConstantAccess staticConstantAccess) { if (lineBounds.containsInclusive(staticConstantAccess.getStartOffset())) { String constName = staticConstantAccess.getConstant().getName(); String clzName = CodeUtils.extractUnqualifiedClassName(staticConstantAccess); if (clzName != null && StringUtils.hasText(constName)) { Collection<? extends TypeScope> allTypes = ModelUtils.resolveType(model, staticConstantAccess); if (allTypes.size() == 1) { TypeScope type = ModelUtils.getFirst(allTypes); ElementQuery.Index index = model.getIndexScope().getIndex(); Set<TypeConstantElement> allConstants = ElementFilter.forName(NameKind.exact(constName)).filter(index.getAllTypeConstants(type)); if (allConstants.isEmpty()) { assert type != null; FileObject fileObject = type.getFileObject(); BaseDocument document = fileObject != null ? GsfUtilities.getDocument(fileObject, false) : null; if (document != null && fileObject.canWrite()) { fix = new IntroduceClassConstantFix(document, staticConstantAccess, (TypeScope) type); } } } } } super.visit(staticConstantAccess); }
@Override public void visit(StaticMethodInvocation methodInvocation) { if (lineBounds.containsInclusive(methodInvocation.getStartOffset())) { String methName = CodeUtils.extractFunctionName(methodInvocation.getMethod()); String clzName = CodeUtils.extractUnqualifiedClassName(methodInvocation); if (clzName != null && StringUtils.hasText(methName)) { Collection<? extends TypeScope> allTypes = ModelUtils.resolveType(model, methodInvocation); if (allTypes.size() == 1) { TypeScope type = ModelUtils.getFirst(allTypes); ElementQuery.Index index = model.getIndexScope().getIndex(); final ElementFilter nameFilter = ElementFilter.forName(NameKind.exact(methName)); final ElementFilter staticFilter = ElementFilter.forStaticModifiers(true); Set<MethodElement> allMethods = ElementFilter.allOf(nameFilter, staticFilter).filter(index.getAllMethods(type)); if (allMethods.isEmpty()) { assert type != null; FileObject fileObject = type.getFileObject(); BaseDocument document = fileObject != null ? GsfUtilities.getDocument(fileObject, true) : null; if (document != null && fileObject.canWrite()) { fix = new IntroduceStaticMethodFix(document, methodInvocation, type); } } } } } super.visit(methodInvocation); }
FileObject workingCopyFileObject = workingCopy.getSnapshot().getSource().getFileObject(); if (root != null) { BaseDocument doc = GsfUtilities.getDocument(workingCopyFileObject, true); try { if (doc != null) {
BaseDocument doc = GsfUtilities.getDocument(jspr.getSnapshot().getSource().getFileObject(), true); Element element = null; try {