Examples of AnalysisContext


Examples of com.google.dart.engine.context.AnalysisContext

  }

  @NotNull
  public AnalysisContext getAnalysisContext(final @NotNull VirtualFile annotatedFile,
                                            final @NotNull String sdkPath) {
    AnalysisContext analysisContext = SoftReference.dereference(myAnalysisContextRef);

    final DartUrlResolver dartUrlResolver = DartUrlResolver.getInstance(myProject, annotatedFile);
    final VirtualFile yamlFile = dartUrlResolver.getPubspecYamlFile();
    final Document cachedDocument = yamlFile == null ? null : FileDocumentManager.getInstance().getCachedDocument(yamlFile);
    final long pubspecYamlTimestamp = yamlFile == null ? -1
                                                       : cachedDocument == null ? yamlFile.getModificationCount()
                                                                                : cachedDocument.getModificationStamp();

    final VirtualFile[] packageRoots = dartUrlResolver.getPackageRoots();

    final VirtualFile contentRoot = ProjectRootManager.getInstance(myProject).getFileIndex().getContentRootForFile(annotatedFile);
    final Module module = ModuleUtilCore.findModuleForFile(annotatedFile, myProject);

    final boolean useExplicitPackageUriResolver = !ApplicationManager.getApplication().isUnitTestMode() &&
                                                  contentRoot != null &&
                                                  module != null &&
                                                  !DartConfigurable.isCustomPackageRootSet(module) &&
                                                  yamlFile == null;

    final boolean sameContext = analysisContext != null &&
                                Comparing.equal(sdkPath, mySdkPath) &&
                                pubspecYamlTimestamp == myPubspecYamlTimestamp &&
                                Comparing.haveEqualElements(packageRoots, myDartPackageRoots) &&
                                (!useExplicitPackageUriResolver || Comparing.equal(contentRoot, myContentRoot));

    if (sameContext) {
      applyChangeSet(analysisContext, annotatedFile);
      myCreatedFiles.clear();
    }
    else {
      final DirectoryBasedDartSdk dirBasedSdk = getDirectoryBasedDartSdkSdk(sdkPath);
      final DartUriResolver dartUriResolver = new DartUriResolver(dirBasedSdk);
      final DartFileAndPackageUriResolver fileAndPackageUriResolver = new DartFileAndPackageUriResolver(myProject, dartUrlResolver);

      final SourceFactory sourceFactory = useExplicitPackageUriResolver
                                          ? new SourceFactory(dartUriResolver, fileAndPackageUriResolver,
                                                              new ExplicitPackageUriResolver(dirBasedSdk, new File(contentRoot.getPath())))
                                          : new SourceFactory(dartUriResolver, fileAndPackageUriResolver);

      analysisContext = AnalysisEngine.getInstance().createAnalysisContext();
      analysisContext.setSourceFactory(sourceFactory);

      final AnalysisOptionsImpl contextOptions = new AnalysisOptionsImpl();
      contextOptions.setEnableAsync(true);
      analysisContext.setAnalysisOptions(contextOptions);

      mySdkPath = sdkPath;
      myPubspecYamlTimestamp = pubspecYamlTimestamp;
      myDartPackageRoots = packageRoots;
      myContentRoot = contentRoot;
View Full Code Here

Examples of com.google.dart.engine.context.AnalysisContext

  private Annotation doHighlightingAndFindIntention(final String message) throws IOException {
    final AnnotationHolderImpl annotationHolder = new AnnotationHolderImpl(new AnnotationSession(myFixture.getFile()));

    final DartInProcessAnnotator annotator = new DartInProcessAnnotator();
    final DartInProcessAnnotator.DartAnnotatorInfo annotatorInfo = annotator.collectInformation(myFixture.getFile());
    final AnalysisContext analysisContext = annotator.doAnnotate(annotatorInfo);
    annotator.apply(myFixture.getFile(), analysisContext, annotationHolder);

    return ContainerUtil.find(annotationHolder, new Condition<Annotation>() {
      @Override
      public boolean value(Annotation action) {
View Full Code Here

Examples of com.google.dart.engine.context.AnalysisContext

  protected AnalysisError[] getErrorsFromAnnotator() {
    final DartInProcessAnnotator annotator = new DartInProcessAnnotator();
    final DartInProcessAnnotator.DartAnnotatorInfo annotatorInfo = annotator.collectInformation(myFixture.getFile());
    if (annotatorInfo == null) return AnalysisError.NO_ERRORS;
    final AnalysisContext analysisContext = annotator.doAnnotate(annotatorInfo);
    final DartFileBasedSource source = DartFileBasedSource.getSource(getProject(), myFixture.getFile().getVirtualFile());
    return analysisContext == null ? AnalysisError.NO_ERRORS : analysisContext.getErrors(source).getErrors();
  }
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.AnalysisContext

    /**
     * Check whether or not the various interprocedural databases we can use
     * exist and are nonempty.
     */
    private void checkDatabases() {
        AnalysisContext analysisContext = AnalysisContext.currentAnalysisContext();
        unconditionalDerefParamDatabase = analysisContext.getUnconditionalDerefParamDatabase();
    }
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.AnalysisContext

    final UnreadFieldsData unreadFields;

    final BugReporter bugReporter;

    public ExplicitSerialization(BugReporter bugReporter) {
        AnalysisContext context = AnalysisContext.currentAnalysisContext();
        unreadFields = context.getUnreadFieldsData();
        this.bugReporter = bugReporter;
    }
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.AnalysisContext

    @Override
    public SourceLineAnnotation getSourceLines() {
        if (sourceLines == null) {
            // Create source line annotation for field on demand
            AnalysisContext currentAnalysisContext = AnalysisContext.currentAnalysisContext();
            if (currentAnalysisContext == null) {
                sourceLines = new SourceLineAnnotation(className, sourceFileName, -1, -1, -1, -1);
            } else {
                SourceInfoMap.SourceLineRange fieldLine = currentAnalysisContext.getSourceInfoMap().getFieldLine(className,
                        fieldName);
                if (fieldLine == null) {
                    sourceLines = new SourceLineAnnotation(className, sourceFileName, -1, -1, -1, -1);
                } else {
                    sourceLines = new SourceLineAnnotation(className, sourceFileName, fieldLine.getStart(), fieldLine.getEnd(),
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.AnalysisContext

            AnalysisContext.currentAnalysisContext().analysisSkippedDueToInvokeDynamic(xmethod);
            return null;
        }

        try {
            AnalysisContext analysisContext = AnalysisContext.currentAnalysisContext();
            JavaClass jclass = getJavaClass(analysisCache, descriptor.getClassDescriptor());
            ConstantPoolGen cpg = getConstantPoolGen(analysisCache, descriptor.getClassDescriptor());

            String methodName = method.getName();
            int codeLength = method.getCode().getLength();
            String superclassName = jclass.getSuperclassName();
            if (codeLength > 6000 && methodName.equals("<clinit>") && superclassName.equals("java.lang.Enum")) {
                analysisContext.getLookupFailureCallback().reportSkippedAnalysis(
                        new JavaClassAndMethod(jclass, method).toMethodDescriptor());
                return null;
            }
            if (analysisContext.getBoolProperty(AnalysisFeatures.SKIP_HUGE_METHODS)) {
                if (codeLength > 6000 || (methodName.equals("<clinit>") || methodName.equals("getContents")) && codeLength > 2000) {
                    analysisContext.getLookupFailureCallback().reportSkippedAnalysis(
                            new JavaClassAndMethod(jclass, method).toMethodDescriptor());
                    return null;
                }
            }
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.AnalysisContext

        boolean hasStubs;

        @Override
        public ClassInfo build() {
            AnalysisContext context = AnalysisContext.currentAnalysisContext();
            FieldInfo fields[];
            MethodInfo methods[];
            if (fieldInfoList.size() == 0) {
                fields = FieldInfo.EMPTY_ARRAY;
            } else {
                fields = fieldInfoList.toArray(new FieldInfo[fieldInfoList.size()]);
            }

            for (Map.Entry<MethodInfo, String> e : bridgedSignatures.entrySet()) {
                MethodInfo method = e.getKey();
                String signature = e.getValue();
                for (MethodInfo m : methodInfoList) {
                    if (m.getName().equals(method.getName()) && m.getSignature().equals(signature)) {
                        context.setBridgeMethod(method, m);

                    }
                }

            }
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.AnalysisContext

    protected PackageMemberAnnotation(@DottedClassName String className, String description) {
        this(className, description, computeSourceFile(className));
    }

    private static String computeSourceFile(String className) {
        AnalysisContext context = AnalysisContext.currentAnalysisContext();

        if (context != null) {
            return context.lookupSourceFile(className);
        }
        return SourceLineAnnotation.UNKNOWN_SOURCE_FILE;

    }
View Full Code Here

Examples of edu.umd.cs.findbugs.ba.AnalysisContext

public class FieldItemSummary extends OpcodeStackDetector implements NonReportingDetector {

    FieldSummary fieldSummary = new FieldSummary();

    public FieldItemSummary(BugReporter bugReporter) {
        AnalysisContext context = AnalysisContext.currentAnalysisContext();
        context.setFieldSummary(fieldSummary);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.