org.netbeans.modules.parsing.api.Source.getDocument()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中org.netbeans.modules.parsing.api.Source.getDocument()方法的一些代码示例,展示了Source.getDocument()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Source.getDocument()方法的具体详情如下:
包路径:org.netbeans.modules.parsing.api.Source
类名称:Source
方法名:getDocument

Source.getDocument介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-modelimpl

private static long getDocumentVersion(Snapshot snapshot) {
  final Document doc = snapshot.getSource().getDocument(false);
  long docVersion = NO_DOCUMENT_VERSION;
  if (doc != null) {
    // use instance hash code as version number to not hold reference to doc itself
    docVersion = System.identityHashCode(doc);
  }
  return docVersion;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor

@CheckForNull
public static BaseDocument getDocument(Source source, boolean forceOpen) {
  BaseDocument bdoc = null;
  Document doc = source.getDocument(true);
  if (doc instanceof BaseDocument) {
    bdoc = (BaseDocument) doc;
  }
  return bdoc;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-css-prep

public Document getDocument() {
  return snapshot.getSource().getDocument(false);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript-refactoring

public static BaseDocument getDocument(Parser.Result info) {
  BaseDocument doc = null;
  if (info != null) {
    doc = (BaseDocument) info.getSnapshot().getSource().getDocument(true);
  }
  return doc;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby

public static BaseDocument getDocument(Result result, boolean forceOpen) {
  return (BaseDocument) result.getSnapshot().getSource().getDocument(forceOpen);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor

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);
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

@Override
public StyledDocument getDocument() {
  final FileObject file = getHandle().resolveFileObject(false);
  if (file == null) {
    return null;
  }
  final Source src = Source.create(file);
  if (src == null) {
    return null;
  }
  final Document doc = src.getDocument(false);
  return (doc instanceof StyledDocument) ?  ((StyledDocument)doc) : null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-java-editor-base

@Override
public void run(Result result, SchedulerEvent event) {
  CompilationInfo info = CompilationInfo.get(result);
  
  if (info == null) {
    return ;
  }
  
  cancel.set(false);
  
  final Document doc = result.getSnapshot().getSource().getDocument(false);
  
  if (!verifyDocument(doc)) return;
  process(info, doc);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor

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);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-parsing-nb

@SuppressWarnings("LeakingThisInConstructor")
public DocListener (final EditorCookie.Observable ec) {
  assert ec != null;
  this.ec = ec;
  this.ec.addPropertyChangeListener(WeakListeners.propertyChange(this, this.ec));
  final Source source = getSourceControl().getSource();
  assert source != null;
  final Document doc = source.getDocument(false);
  if (doc != null) {
    assignDocumentListener(doc);
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

@Override
protected final Long isDirty() {
  final FileObject file = getHandle().resolveFileObject(false);
  if (file == null) {
    return null;
  }
  final Source source = Source.create(file);
  if (source != null) {
    Document doc = source.getDocument(false);
    if (doc != null) {
      return DocumentUtilities.getDocumentTimestamp(doc);
    }
  }
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-html-angular

private TokenSequence<HTMLTokenId> getHtmlTs(CodeCompletionContext ccContext) {
  final Document document = ccContext.getParserResult().getSnapshot().getSource().getDocument(false);
  TokenSequence<HTMLTokenId> result = null;
  if (document != null) {
    final TokenSequence<HTMLTokenId>[] value = new TokenSequence[1];
    document.render(new Runnable() {
      @Override
      public void run() {
        TokenHierarchy<Document> th = TokenHierarchy.get(document);
        value[0] = th.tokenSequence(HTMLTokenId.language());
      }
    });
    result = value[0];
  }
  return result;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-java-editor-base

@Override
public void run (Result parseResult, SchedulerEvent event) {
  resume();
  CompilationInfo info = CompilationInfo.get(parseResult);
  if (info == null) {
    return ;
  }
  Document doc = parseResult.getSnapshot().getSource().getDocument(false);
  
  process(info, doc, event);
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

public final void update (CharSequence content) throws IOException {
  if (content == null) {
    update();
  } else {
    if (filter != null) {
      final FileObject file = handle.resolveFileObject(false);
      if (file != null) {
        final Source source = Source.create(file);
        if (source != null && source.getDocument(false) == null) {
          content = filter.filterCharSequence(content);
        }
      }
    }
    this.text = toString(content);
  }
  this.tokens = null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-editor

@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);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

public void perform() {
  final Document document = parserResult.getSnapshot().getSource().getDocument(false);
  if (document instanceof BaseDocument) {
    baseDocument = (BaseDocument) document;
    editList = new EditList(baseDocument);
    processExistingUses();
    processSelections();
    editList.apply();
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

private static Options createOptions(final PHPParseResult parserResult) {
  Document document = parserResult.getSnapshot().getSource().getDocument(false);
  CodeStyle codeStyle = CodeStyle.get(document);
  return new Options(codeStyle, parserResult.getModel().getFileScope().getFileObject());
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-html-custom

@Override
public void implement() throws Exception {
  Configuration conf = Configuration.get(snapshot.getSource().getFileObject());
  Tag tag = conf.getTag(elementName);
  if(tag != null) {
    conf.remove(tag);
    conf.store();
    LexerUtils.rebuildTokenHierarchy(snapshot.getSource().getDocument(true));
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-html-custom

@Override
public void implement() throws Exception {
  Configuration conf = Configuration.get(snapshot.getSource().getFileObject());
  conf.add(new Tag(elementName));
  conf.store();
  LexerUtils.rebuildTokenHierarchy(snapshot.getSource().getDocument(true));
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

public DiffContext(CompilationInfo copy, Set<Tree> syntheticTrees) {
  this.tokenSequence = copy.getTokenHierarchy().tokenSequence(JavaTokenId.language());
  this.mainCode = this.origText = copy.getText();
  this.style = getCodeStyle(copy);
  this.context = JavaSourceAccessor.getINSTANCE().getJavacTask(copy).getContext();
  this.mainUnit = this.origUnit = (JCCompilationUnit) copy.getCompilationUnit();
  this.trees = copy.getTrees();
  this.doc = copy.getSnapshot().getSource().getDocument(false); //TODO: true or false?
  this.positionConverter = copy.getPositionConverter();
  this.file = copy.getFileObject();
  this.syntheticTrees = syntheticTrees;
  
  this.textLength = copy.getSnapshot() == null ? Integer.MAX_VALUE : copy.getSnapshot().getOriginalOffset(copy.getSnapshot().getText().length());
  this.blockSequences = new BlockSequences(this.tokenSequence, doc, textLength);
  
  this.forceInitialComment = false;
}

相关文章