Skip to content

Commit

Permalink
Refactor startup code, including part and property tracking.
Browse files Browse the repository at this point in the history
  • Loading branch information
gbr committed Mar 11, 2023
1 parent 80492fa commit 07781e2
Show file tree
Hide file tree
Showing 28 changed files with 763 additions and 325 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Ignore certain Eclipse related files
.classpath
.settings/
bin/
target/
8 changes: 0 additions & 8 deletions .mvn/extensions.xml

This file was deleted.

6 changes: 6 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## The MIT License

Copyright (c) 2006-2018 The IndentGuide Authors.
Copyright (c) 2006-2023 The IndentGuide Authors.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 12 additions & 0 deletions net.certiv.tools.indentguide.feature/.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.pde.FeatureBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.FeatureNature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
10 changes: 10 additions & 0 deletions net.certiv.tools.indentguide.plugin.test/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
34 changes: 34 additions & 0 deletions net.certiv.tools.indentguide.plugin.test/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>net.certiv.tools.indentguide.plugin.test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
10 changes: 10 additions & 0 deletions net.certiv.tools.indentguide.plugin.test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: tychotest.test
Bundle-Vendor: tychotest
Bundle-SymbolicName: net.certiv.tools.indentguide.plugin.test
Bundle-Version: 2.1.0.qualifier
Fragment-Host: net.certiv.tools.indentguide;bundle-version="2.1.0.qualifier"
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: junit-jupiter-api
Automatic-Module-Name: tychotest.test
2 changes: 2 additions & 0 deletions net.certiv.tools.indentguide.plugin.test/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin.includes = META-INF/,\
.
15 changes: 15 additions & 0 deletions net.certiv.tools.indentguide.plugin.test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<packaging>eclipse-test-plugin</packaging>

<parent>
<groupId>net.certiv</groupId>
<artifactId>net.certiv.tools.indentguide.parent</artifactId>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>net.certiv.tools.indentguide.plugin.test</artifactId>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package net.certiv.tools.indentguide;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class ActivatorTest {

@Test
public void testActivatorId() {
Assertions.assertNotNull(Activator.PLUGIN_ID);
}

}
12 changes: 12 additions & 0 deletions net.certiv.tools.indentguide.plugin/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
2 changes: 0 additions & 2 deletions net.certiv.tools.indentguide.plugin/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ bin.includes = plugin.xml,\
META-INF/,\
OSGI-INF/,\
icons/
src.excludes = src/test/java/,\
src/test/resources/
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static Activator getDefault() {
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
log("Startup");
log("Starting...");
}

@Override
Expand All @@ -44,15 +44,31 @@ public void stop(BundleContext context) throws Exception {
super.stop(context);
}

// ------------------------------------------

public static void log(Throwable e) {
plugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage()));
}

public static void log(String fmt, Object... args) {
plugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, PREFIX + String.format(fmt, args)));
String msg = print(PREFIX + String.format(fmt, args));
plugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, msg));
}

public static void log(MsgBuilder mb) {
plugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, PREFIX + mb.toString()));
String msg = print(PREFIX + mb.toString());
plugin.getLog().log(new Status(IStatus.INFO, PLUGIN_ID, msg));
}

public static void log(Throwable e) {
plugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage()));
private static String print(String msg) {
StackTraceElement caller = Thread.currentThread().getStackTrace()[3];
return info(caller.getClassName(), caller.getLineNumber(), msg);
}

private static String info(String clsname, int line, String msg) {
if (clsname.startsWith(PLUGIN_ID)) {
clsname = clsname.substring(PLUGIN_ID.length() + 1);
}
return String.format("%s:%s \t%s", clsname, line, msg);
}
}
Loading

0 comments on commit 07781e2

Please sign in to comment.