com.intellij.openapi.diagnostic.Logger Java Examples

The following examples show how to use com.intellij.openapi.diagnostic.Logger. 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: TabNineProcess.java    From tabnine-intellij with MIT License 6 votes vote down vote up
String communicateLine(String req) {
    synchronized (this) {
        if (this.isDead()) {
            Logger.getInstance(getClass()).info("TabNine cannot respond to the request because the process is dead.");
            return null;
        }
        try {
            byte[] toWrite = req.getBytes(StandardCharsets.UTF_8);
            synchronized (this) {
                this.proc.getOutputStream().write(toWrite);
                this.proc.getOutputStream().flush();
                return this.procLineReader.readLine();
            }
        } catch (IOException e) {
            Logger.getInstance(getClass()).info("Exception communicating with TabNine: " + e);
            try {
                this.restartTabNine(true);
            } catch (IOException e2) {
                Logger.getInstance(getClass()).error("Error restarting TabNine: " + e2);
                this.proc = null;
            }
        }
    }
    return null;
}
 
Example #2
Source File: ExecutionUtil.java    From aem-ide-tooling-4-intellij with Apache License 2.0 6 votes vote down vote up
public static void runAndWait(final @NotNull WaitableRunner runner) {
    try {
        if(runner.isAsynchronous()) {
            final CountDownLatch stopSignal = runner.getLatch();
            Logger.getInstance("#com.headwire.aem.tooling.intellij.util.ExecutionUtil").debug("Is Application Dispatcher Thread: " + ApplicationManager.getApplication().isDispatchThread());
            ApplicationManager.getApplication().invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        runner.run();
                    } finally {
                        // Make sure the latch is released
                        stopSignal.countDown();
                    }
                }
            });
            //AS TODO: re-opening another project will start this method as part of the when project is initialized. The runnable task
            //AS TODO: is not started and the next step waits forever.
            stopSignal.await();
        } else {
            runner.run();
        }
    } catch(Exception e) {
        runner.handleException(e);
    }
}
 
Example #3
Source File: ToolWindowFactory.java    From adc with Apache License 2.0 6 votes vote down vote up
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {
    ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
    JPanel framePanel = createPanel(project);
    disableAll();

    AndroidDebugBridge adb = AndroidSdkUtils.getDebugBridge(project);
    if (adb == null) {
        return;
    }

    if(adb.isConnected()){
        ToolWindowFactory.this.adBridge = adb;
        Logger.getInstance(ToolWindowFactory.class).info("Successfully obtained debug bridge");
        AndroidDebugBridge.addDeviceChangeListener(deviceChangeListener);
        updateDeviceComboBox();
    } else {
        Logger.getInstance(ToolWindowFactory.class).info("Unable to obtain debug bridge");
        String msg = MessageFormat.format(resourceBundle.getString("error.message.adb"), "");
        Messages.showErrorDialog(msg, resourceBundle.getString("error.title.adb"));
    }

    Content content = contentFactory.createContent(framePanel, "", false);
    toolWindow.getContentManager().addContent(content);
}
 
Example #4
Source File: GradleBuildModel.java    From ok-gradle with Apache License 2.0 6 votes vote down vote up
/**
 * Runs the given supplier and returns the result if no exception was thrown. If an exception was thrown then
 * log it to back intellijs logs and the AndroidStudioCrashReporter and return null.
 *
 * @param supplier supplier to run
 * @return supplied value or null if an exception was thrown
 */
@Nullable
static <T> T tryOrLog(@NotNull Supplier<T> supplier) {
  try {
    return supplier.get();
  } catch (Exception e) {
    if (e instanceof ControlFlowException) {
      // Control-Flow exceptions should not be logged and reported.
      return null;
    }
    Logger logger = Logger.getInstance(ProjectBuildModel.class);
    logger.error(e);

    // TODO: this would be a place to report crash
    // Since this would have caused an IDE crash we still want to report any exceptions for monitoring.
    // StudioCrashReporter reporter = StudioCrashReporter.getInstance();
    // reporter.submit(new StudioExceptionReport.Builder().setThrowable(e, false).build());
    return null;
  }
}
 
Example #5
Source File: Util.java    From sourcegraph-jetbrains with Apache License 2.0 6 votes vote down vote up
public static String exec(String cmd, String dir) throws IOException {
    Logger.getInstance(Util.class).debug("exec cmd='" + cmd + "' dir="+dir);

    // Create the process.
    Process p = Runtime.getRuntime().exec(cmd, null, new File(dir));
    BufferedReader stdout = new BufferedReader(new InputStreamReader(p.getInputStream()));
    BufferedReader stderr = new BufferedReader(new InputStreamReader(p.getErrorStream()));

    // Log any stderr ouput.
    Logger logger = Logger.getInstance(Util.class);
    String s;
    while ((s = stderr.readLine()) != null) {
        logger.debug(s);
    }

    String out = new String();
    for (String l; (l = stdout.readLine()) != null; out += l + "\n");
    return out;
}
 
Example #6
Source File: Util.java    From sourcegraph-jetbrains with Apache License 2.0 6 votes vote down vote up
public static RepoInfo repoInfo(String fileName) {
    String fileRel = "";
    String remoteURL = "";
    String branch = "";
    try{
        // Determine repository root directory.
        String fileDir = fileName.substring(0, fileName.lastIndexOf("/"));
        String repoRoot = gitRootDir(fileDir);

        // Determine file path, relative to repository root.
        fileRel = fileName.substring(repoRoot.length()+1);
        remoteURL = configuredGitRemoteURL(repoRoot);
        branch = gitBranch(repoRoot);

        // If on a branch that does not exist on the remote, use "master" instead.
        if (!isRemoteBranch(branch, repoRoot)) {
            branch = "master";
        }
    } catch (Exception err) {
        Logger.getInstance(Util.class).info(err);
        err.printStackTrace();
    }
    return new RepoInfo(fileRel, remoteURL, branch);
}
 
Example #7
Source File: ParseTreeContextualMenu.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void exportToSvg(UberTreeViewer parseTreeViewer, File file, boolean useTransparentBackground) {
    DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
    Document document = domImpl.createDocument("http://www.w3.org/2000/svg", "svg", null);
    SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

    if (!useTransparentBackground) {
        svgGenerator.setColor(JBColor.WHITE);
        svgGenerator.fillRect(0, 0, parseTreeViewer.getWidth(), parseTreeViewer.getHeight());
    }
    parseTreeViewer.paint(svgGenerator);

    try {
        svgGenerator.stream(file.getAbsolutePath(), true);
    } catch (SVGGraphics2DIOException e) {
        Logger.getInstance(ParseTreeContextualMenu.class)
                .error("Error while exporting parse tree to SVG file " + file.getAbsolutePath(), e);
    }
}
 
Example #8
Source File: DslCompilerService.java    From dsl-compiler-client with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public DslCompilerService() {
	final Logger logger = com.intellij.openapi.diagnostic.Logger.getInstance("DSL Platform");
	final DslContext context = new DslContext(logger);
	context.put(Download.INSTANCE, null);
	Thread setup = new Thread(new Runnable() {
		@Override
		public void run() {
			try {
				setupCompiler(logger, context);
			} catch (Throwable e) {
				logger.error(e.getMessage());
			}
		}
	});
	setup.start();
}
 
Example #9
Source File: TabNineProcess.java    From tabnine-intellij with MIT License 6 votes vote down vote up
<T> T request(Request<T> r) {
    Gson gson = new GsonBuilder().create();
    Map<String, Object> jsonObject = new HashMap<>();
    Map<String, Object> requestMap = new HashMap<>();
    requestMap.put(r.name(), r);
    jsonObject.put("version", "2.0.2");
    jsonObject.put("request", requestMap);
    String rJson = gson.toJson(jsonObject) + "\n";
    String responseJson = this.communicateLine(rJson);
    if (responseJson == null) {
        return null;
    } else {
        T response = gson.fromJson(responseJson, r.response());
        if (r.validate(response)) {
            return response;
        } else {
            try {
                this.restartTabNine(false);
            } catch (IOException e) {
                Logger.getInstance(getClass()).error("Error restarting TabNine: " + e);
            }
            return null;
        }
    }
}
 
Example #10
Source File: ParseTreeContextualMenu.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void exportToImage(UberTreeViewer parseTreeViewer, File file, boolean useTransparentBackground, String imageFormat) {
    int imageType = useTransparentBackground ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB;
    BufferedImage bi = UIUtil.createImage(parseTreeViewer.getWidth(), parseTreeViewer.getHeight(), imageType);
    Graphics graphics = bi.getGraphics();

    if (!useTransparentBackground) {
        graphics.setColor(JBColor.WHITE);
        graphics.fillRect(0, 0, parseTreeViewer.getWidth(), parseTreeViewer.getHeight());
    }

    parseTreeViewer.paint(graphics);

    try {
        if (!ImageIO.write(bi, imageFormat, file)) {
            Notification notification = new Notification(
                    "ANTLR 4 export",
                    "Error while exporting parse tree to file " + file.getAbsolutePath(),
                    "unknown format '" + imageFormat + "'?",
                    NotificationType.WARNING
            );
            Notifications.Bus.notify(notification);
        }
    } catch (IOException e) {
        Logger.getInstance(ParseTreeContextualMenu.class)
                .error("Error while exporting parse tree to file " + file.getAbsolutePath(), e);
    }
}
 
Example #11
Source File: BaseHaxeGenerateHandler.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
protected void doInvoke(final Project project,
                        final Editor editor,
                        final PsiFile file,
                        final Collection<HaxeNamedElementNode> selectedElements,
                        final BaseCreateMethodsFix createMethodsFix) {
  Runnable runnable = new Runnable() {
    public void run() {
      createMethodsFix.addElementsToProcessFrom(selectedElements);
      createMethodsFix.beforeInvoke(project, editor, file);

      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        public void run() {
          try {
            createMethodsFix.invoke(project, editor, file);
          }
          catch (IncorrectOperationException ex) {
            Logger.getInstance(getClass().getName()).error(ex);
          }
        }
      });
    }
  };

  if (CommandProcessor.getInstance().getCurrentCommand() == null) {
    CommandProcessor.getInstance().executeCommand(project, runnable, getClass().getName(), null);
  }
  else {
    runnable.run();
  }
}
 
Example #12
Source File: DslCompilerService.java    From dsl-compiler-client with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void setupCompiler(Logger logger, DslContext context) throws InterruptedException {
	if (!Main.processContext(context, Arrays.<CompileParameter>asList(Download.INSTANCE, DslCompiler.INSTANCE))) {
		logger.warn("Unable to setup DSL Platform client");
	}
	final String path = context.get(DslCompiler.INSTANCE);
	if (path == null) {
		logger.error("Unable to setup dsl-compiler.exe. Please check if Mono/.NET is installed and available on path.");
	} else {
		final File compiler = new File(path);
		logger.info("DSL Platform compiler found at: " + compiler.getAbsolutePath());
		Either<DslCompiler.TokenParser> trySetup = DslCompiler.setupServer(context, compiler);
		if (trySetup.isSuccess()) {
			tokenParser = trySetup.get();
			Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
				@Override
				public void run() {
					try {
						tokenParser.close();
						tokenParser = null;
					} catch (Exception ignore) {
					}
				}
			}));
			Thread.sleep(2000);
			for (Runnable r : notifications) {
				r.run();
			}
		}
	}
}
 
Example #13
Source File: HaxeDebugTimeLog.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public HaxeDebugTimeLog(@NotNull Logger log, Since since) {
  myLog = log;
  myTimeStamps = new LinkedList<TimeStamp>();
  mySince = since;
  myDateFormatter = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss.SSS");
  myDate = new Date(System.currentTimeMillis());
}
 
Example #14
Source File: Fix.java    From CppTools with Apache License 2.0 5 votes vote down vote up
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor problemDescriptor) {
  final PsiElement psiElement = problemDescriptor.getPsiElement();
  final PsiFile psiFile = psiElement.getContainingFile();
  final Editor editor = FileEditorManager.getInstance(project).openTextEditor(
    new OpenFileDescriptor(project, psiFile.getVirtualFile(), psiElement.getTextOffset()), false
  );
  try {
    invoke(project, editor, psiFile);
  } catch (IncorrectOperationException e) {
    Logger.getInstance(getClass().getName()).error(e);
  }
}
 
Example #15
Source File: PantsCyclicDependenciesModifier.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void modify(@NotNull ProjectInfo projectInfo, @NotNull PantsCompileOptionsExecutor executor, @NotNull Logger log) {
  final Set<Map.Entry<String, TargetInfo>> originalEntries =
    new HashSet<>(projectInfo.getTargets().entrySet());
  for (Map.Entry<String, TargetInfo> nameAndInfo : originalEntries) {
    final String targetName = nameAndInfo.getKey();
    final TargetInfo targetInfo = nameAndInfo.getValue();
    if (!projectInfo.getTargets().containsKey(targetName)) {
      // already removed
      continue;
    }
    for (String dependencyTargetName : targetInfo.getTargets()) {
      TargetInfo dependencyTargetInfo = projectInfo.getTarget(dependencyTargetName);
      if (dependencyTargetInfo != null && dependencyTargetInfo.dependOn(targetName)) {

        if (targetName.equals(dependencyTargetName)) {
          throw new PantsException(String.format("Self cyclic dependency found %s", targetName));
        }

        log.info(String.format("Found cyclic dependency between %s and %s", targetName, dependencyTargetName));

        final String combinedTargetName = combinedTargetsName(targetName, dependencyTargetName);
        final TargetInfo combinedInfo = targetInfo.union(dependencyTargetInfo);
        combinedInfo.removeDependency(targetName);
        combinedInfo.removeDependency(dependencyTargetName);
        projectInfo.addTarget(combinedTargetName, combinedInfo);

        projectInfo.replaceDependency(targetName, combinedTargetName);
        projectInfo.removeTarget(targetName);

        projectInfo.replaceDependency(dependencyTargetName, combinedTargetName);
        projectInfo.removeTarget(dependencyTargetName);
      }
    }
  }
}
 
Example #16
Source File: PantsCommonSourceRootModifier.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void modify(@NotNull ProjectInfo projectInfo, @NotNull PantsCompileOptionsExecutor executor, @NotNull Logger log) {
  // IntelliJ doesn't support when several modules have the same source root
  // so, for source roots that point at multiple targets, we need to convert those so that
  // they have only one target that owns them.
  // to do that, we
  // - find or create a target to own the source root
  // - for each target that depends on that root,
  //   we replace the root with a dependency on the new target

  final Map<ContentRoot, List<Pair<String, TargetInfo>>> sourceRoot2Targets = getSourceRoot2TargetMapping(projectInfo);
  if (sourceRoot2Targets.isEmpty()) {
    return;
  }

  for (Map.Entry<ContentRoot, List<Pair<String, TargetInfo>>> entry : sourceRoot2Targets.entrySet()) {
    final List<Pair<String, TargetInfo>> targetNameAndInfos = entry.getValue();
    final ContentRoot commonContentRoot = entry.getKey();
    if (targetNameAndInfos.size() <= 1) {
      continue;
    }

    final Pair<String, TargetInfo> commonTargetNameAndInfo =
      createTargetForCommonSourceRoot(executor.getBuildRoot().getPath(), targetNameAndInfos, commonContentRoot);

    projectInfo.addTarget(commonTargetNameAndInfo.getFirst(), commonTargetNameAndInfo.getSecond());
    for (Pair<String, TargetInfo> nameAndInfo : targetNameAndInfos) {
      nameAndInfo.getSecond().getRoots().remove(commonContentRoot);
      nameAndInfo.getSecond().addDependency(commonTargetNameAndInfo.getFirst());
    }
  }
}
 
Example #17
Source File: PantsTargetNamesShortenerModifier.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void modify(@NotNull ProjectInfo projectInfo, @NotNull PantsCompileOptionsExecutor executor, @NotNull Logger log) {
  final List<String> longTargetNames = projectInfo.getTargets()
    .keySet()
    .stream()
    .filter(s -> s.length() > MAX_MODULE_NAME_LENGTH)
    .collect(Collectors.toList());

  for (String targetName : longTargetNames) {
    final String newTargetName = StringUtil.trimMiddle(targetName, MAX_MODULE_NAME_LENGTH);
    log.info(targetName + " is too long! Will replace with " + newTargetName);
    projectInfo.renameTarget(targetName, newTargetName);
  }
}
 
Example #18
Source File: PantsEmptyTargetRemover.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void modify(@NotNull ProjectInfo projectInfo, @NotNull PantsCompileOptionsExecutor executor, @NotNull Logger log) {
  final List<String> emptyTargets = new ArrayList<>();
  do {
    emptyTargets.clear();
    for (Map.Entry<String, TargetInfo> targetInfoEntry : projectInfo.getTargets().entrySet()) {
      final String targetName = targetInfoEntry.getKey();
      final TargetInfo targetInfo = targetInfoEntry.getValue();
      if (targetInfo.isEmpty()) {
        emptyTargets.add(targetName);
      }
    }
    projectInfo.removeTargets(emptyTargets);
  } while (!emptyTargets.isEmpty());
}
 
Example #19
Source File: ShowPreprocessedCommand.java    From CppTools with Apache License 2.0 5 votes vote down vote up
public void doExecute() {
  try {
    int index = fileName.lastIndexOf('.');
    File tempFile = File.createTempFile(
      fileName.substring(fileName.lastIndexOf(File.separatorChar) + 1, index != -1 ? index:fileName.length()),
      index != -1 ? fileName.substring(index):""
    );
    String s = "//  + Preprocessed Text for " + fileName + " ("+start + "," + end + "), selection follows below:\n";
    StringTokenizer tokenizer = new StringTokenizer(editor.getDocument().getCharsSequence().subSequence(start, end).toString(), "\n");
    while (tokenizer.hasMoreElements()) {
      s += "// " + tokenizer.nextToken() + "\n";
    }
    s += myText;
    FileUtil.writeToFile(tempFile, s.getBytes());
    VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempFile);
    if (virtualFile != null) {
      Project project = editor.getProject();
      OpenFileDescriptor descriptor = new OpenFileDescriptor(project, virtualFile);

      FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
    } else {
      Logger.getInstance(getClass().getName()).error(
        "Unexpected problem finding virtual file for "+tempFile.getPath());
    }
  } catch (IOException ex) {
    Logger.getInstance(getClass().getName()).error(ex);
  }
}
 
Example #20
Source File: CMakeWorkspaceOverride.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static void clearClasspath(Module module) {
  ClasspathStorage.setStorageType(
      ModuleRootManager.getInstance(module), ClassPathStorageUtil.DEFAULT_STORAGE);
  Logger.getInstance(CMakeWorkspaceOverride.class).warn("Had to clear CMake classpath");
  EventLoggingService.getInstance()
      .logEvent(CMakeWorkspaceOverride.class, "cleared-cmake-classpath", ImmutableMap.of());
}
 
Example #21
Source File: TabNineCompletionContributor.java    From tabnine-intellij with MIT License 5 votes vote down vote up
TabNineProcess getProcOrPrintError() {
    synchronized (this) {
        if (this.proc == null) {
            Logger.getInstance(getClass()).info("Can't get completions because TabNine process is not started yet.");
        }
        return this.proc;
    }
}
 
Example #22
Source File: RequestBuilder.java    From leetcode-editor with Apache License 2.0 5 votes vote down vote up
public <T> T connect(@NotNull HttpRequests.RequestProcessor<T> processor, T errorValue, @Nullable Logger logger) {
    try {
        return connect(processor);
    }
    catch (Throwable e) {
        if (logger != null) {
            logger.warn(e);
        }
        return errorValue;
    }
}
 
Example #23
Source File: DependenciesModelImpl.java    From ok-gradle with Apache License 2.0 5 votes vote down vote up
@Override
public void remove(@NotNull DependencyModel dependency) {
  if (!(dependency instanceof me.scana.okgradle.internal.dsl.model.dependencies.DependencyModelImpl)) {
    Logger.getInstance(DependenciesModelImpl.class)
      .warn("Tried to remove an unknown dependency type!");
    return;
  }
  GradleDslElement dependencyElement = ((DependencyModelImpl)dependency).getDslElement();
  GradleDslElement parent = dependencyElement.getParent();
  if (parent instanceof GradleDslMethodCall) {
    GradleDslMethodCall methodCall = (GradleDslMethodCall)parent;
    List<GradleDslExpression> arguments = methodCall.getArguments();
    if (arguments.size() == 1 && arguments.get(0).equals(dependencyElement)) {
      // If this is the last argument, remove the method call altogether.
      myDslElement.removeProperty(methodCall);
    }
    else {
      methodCall.remove(dependencyElement);
    }
  }
  else if (parent instanceof GradleDslExpressionList) {
    List<GradleDslExpression> expressions = ((GradleDslExpressionList)parent).getExpressions();
    if (expressions.size() == 1 && expressions.get(0).equals(dependencyElement)) {
      if (parent.getParent() instanceof GradleDslMethodCall) {
        // We need to delete up two levels if this is a method call.
        myDslElement.removeProperty(parent.getParent());
      }
      else {
        myDslElement.removeProperty(parent);
      }
    }
    else {
      ((GradleDslExpressionList)parent).removeElement(dependencyElement);
    }
  }
  else {
    myDslElement.removeProperty(dependencyElement);
  }
}
 
Example #24
Source File: Open.java    From sourcegraph-jetbrains with Apache License 2.0 5 votes vote down vote up
@Override
void handleFileUri(String uri) {
    Logger logger = Logger.getInstance(this.getClass());
    // Open the URL in the browser.
    try {
        Desktop.getDesktop().browse(URI.create(uri));
    } catch (IOException err) {
        logger.debug("failed to open browser");
        err.printStackTrace();
    }
    return;
}
 
Example #25
Source File: FileAction.java    From sourcegraph-jetbrains with Apache License 2.0 4 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
    Logger logger = Logger.getInstance(this.getClass());

    // Get project, editor, document, file, and position information.
    final Project project = e.getProject();
    if (project == null) {
        return;
    }
    Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
    if (editor == null) {
        return;
    }
    Document currentDoc = editor.getDocument();
    if (currentDoc == null) {
        return;
    }
    VirtualFile currentFile = FileDocumentManager.getInstance().getFile(currentDoc);
    if (currentFile == null) {
        return;
    }
    SelectionModel sel = editor.getSelectionModel();

    // Get repo information.
    RepoInfo repoInfo = Util.repoInfo(currentFile.getPath());
    if (repoInfo.remoteURL == "") {
        return;
    }

    // Build the URL that we will open.
    String productName = ApplicationInfo.getInstance().getVersionName();
    String productVersion = ApplicationInfo.getInstance().getFullVersion();
    String uri;
    try {
        LogicalPosition start = editor.visualToLogicalPosition(sel.getSelectionStartPosition());
        LogicalPosition end = editor.visualToLogicalPosition(sel.getSelectionEndPosition());
        uri = Util.sourcegraphURL(project)+"-/editor"
                + "?remote_url=" + URLEncoder.encode(repoInfo.remoteURL, "UTF-8")
                + "&branch=" + URLEncoder.encode(repoInfo.branch, "UTF-8")
                + "&file=" + URLEncoder.encode(repoInfo.fileRel, "UTF-8")
                + "&editor=" + URLEncoder.encode("JetBrains", "UTF-8")
                + "&version=" + URLEncoder.encode(Util.VERSION, "UTF-8")
                + "&utm_product_name=" + URLEncoder.encode(productName, "UTF-8")
                + "&utm_product_version=" + URLEncoder.encode(productVersion, "UTF-8")
                + "&start_row=" + URLEncoder.encode(Integer.toString(start.line), "UTF-8")
                + "&start_col=" + URLEncoder.encode(Integer.toString(start.column), "UTF-8")
                + "&end_row=" + URLEncoder.encode(Integer.toString(end.line), "UTF-8")
                + "&end_col=" + URLEncoder.encode(Integer.toString(end.column), "UTF-8");
    } catch (UnsupportedEncodingException err) {
        logger.debug("failed to build URL");
        err.printStackTrace();
        return;
    }

    handleFileUri(uri);
}
 
Example #26
Source File: HaxeDebugTimeLog.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
public HaxeDebugTimeLog(@Nullable String messagePrefix, Since since) {
  this(Logger.getInstance(messagePrefix), since);
  myLog.setLevel(Level.DEBUG);
}
 
Example #27
Source File: HaxeDebugTimeLog.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
public void log(@NotNull Logger logger) {
  logger.debug(buildLogMsg(false, null, null));
}
 
Example #28
Source File: HaxeDebugTimeLog.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
public void log(@NotNull Logger logger, boolean showTimeStamp, @Nullable TimeStamp first, @Nullable TimeStamp previous) {
  logger.debug(buildLogMsg(showTimeStamp, first, previous));
}
 
Example #29
Source File: Symfony2ProjectComponent.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
public static Logger getLogger() {
    return LOG;
}
 
Example #30
Source File: LogviewFactory.java    From logviewer with Apache License 2.0 4 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {

    final File adb = AndroidSdkUtils.getAdb(project);
    ExecutionManager.getInstance(project).getContentManager();

    RunnerLayoutUi layoutUi = RunnerLayoutUi.Factory.getInstance(project).create("LogViewer", TOOL_WINDOW_ID, "Logview Tools", project);

    toolWindow.setIcon(LogviewerPluginIcons.TOOL_ICON);
    toolWindow.setAvailable(true, null);
    toolWindow.setToHideOnEmptyContent(true);
    toolWindow.setTitle(TOOL_WINDOW_ID);


    DeviceContext deviceContext = new DeviceContext();

    Content logcatContent = createLogcatContent(layoutUi, project, deviceContext);
    final LogView logcatView = logcatContent.getUserData(LOG_VIEW_KEY);
    layoutUi.addContent(logcatContent, 0, PlaceInGrid.center, false);

    final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), project);
    loadingPanel.add(layoutUi.getComponent(), BorderLayout.CENTER);

    final ContentManager contentManager = toolWindow.getContentManager();
    Content c = contentManager.getFactory().createContent(loadingPanel, "", true);
    c.putUserData(LOG_VIEW_KEY, logcatView);
    contentManager.addContent(c);
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            logcatView.activate();
        }
    }, project.getDisposed());


    if (adb != null) {
        loadingPanel.setLoadingText("Initializing ADB");
        loadingPanel.startLoading();

        //ListenableFuture<AndroidDebugBridge> future = AdbService.getInstance().getDebugBridge(adb);
        ListenableFuture<AndroidDebugBridge> future = AdbBridgeFactory.getAdb(adb);
        Futures.addCallback(future, new FutureCallback<AndroidDebugBridge>() {
            @Override
            public void onSuccess(@Nullable AndroidDebugBridge bridge) {
                Logger.getInstance(LogviewFactory.class).info("Successfully obtained debug bridge");
                loadingPanel.stopLoading();
            }

            @Override
            public void onFailure(@NotNull Throwable t) {
                loadingPanel.stopLoading();
                Logger.getInstance(LogviewFactory.class).info("Unable to obtain debug bridge", t);
                String msg;
                if (t.getMessage() != null) {
                    msg = t.getMessage();
                } else {
                    msg = String.format("Unable to establish a connection to adb",
                            ApplicationNamesInfo.getInstance().getProductName(), adb.getAbsolutePath());
                }
                Messages.showErrorDialog(msg, "ADB Connection Error");
            }
        }, EdtExecutor.INSTANCE);
    } else {
        logcatView.showHint("No adb connection!.\n\nDrag and drop log files to view them.");
    }
}